package creatType.Singleton;

public class Main {

    public static void main(String[] args) {
        Resource r1 = Singleton1.getSingleton();
        r1.doSomeThings();

        // 只要jvm启动,将Singleton2加载到内存中时static变量就实例化
        Resource r2 = Singleton2.getSingleton();
        r2.doSomeThings();
        
        Resource r3 = Singleton3.getSingleton();
        r3.doSomeThings();

        Resource r11 = Singleton1.getSingleton();
        Resource r22 = Singleton2.getSingleton();
        Resource r33 = Singleton3.getSingleton();

        System.out.println(r1 == r11);
        System.out.println(r2 == r22);
        System.out.println(r3 == r33);
    }
}
